const fs = require('fs')

const dir = ['approvals', 'attendances', 'departments', 'employees', 'permission', 'salarys', 'setting', 'social']

const obj = {
  approvals: { name: 'Approvals', title: '审批', icon: 'tree-table' },
  attendances: { name: 'Attendances', title: '考勤', icon: 'skill' },
  departments: { name: 'Departments', title: '组织架构', icon: 'tree' },
  employees: { name: 'Employees', title: '员工', icon: 'people' },
  permission: { name: 'Permissions', title: '权限管理', icon: 'lock' },
  salarys: { name: 'Salarys', title: '工资', icon: 'money' },
  setting: { name: 'Settings', title: '公司设置', icon: 'setting' },
  social: { name: 'Social_securitys', title: '社保', icon: 'table' }
}

dir.forEach(item => {
  fs.existsSync('dynamicModules') || fs.mkdirSync('dynamicModules')
  fs.writeFileSync('./dynamicModules/' + item + '.js', `
import Layout from '@/layout'
export default {
  path: '/${item}',
  component: Layout,
  children: [
    {
      path: '',
      name: '${obj[item].name}',
      component: () => import('@/views/${item}'),
      meta: { title: '${obj[item].title}', icon: '${obj[item].icon}' }
    }
  ]
}
`)
})
